/* TestTools - Decompiled by JCavaj
 * Visit http://www.bysoft.se/sureshot/jcavaj/
 */
package TestTools;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Calendar;

public class TestTools
{
    private static final boolean ASSERTIONS_ENABLED = true;
    private static final String LOG_FILENAME = "DebugOutput.log";
    private static final String TEST_FILENAME = "TestOutput.log";
    private static TestTools mTestTools;
    private PrintStream mLog;
    private PrintStream mTest;
    private Calendar mCalendar;
    
    private TestTools() {
	try {
	    mLog = new PrintStream(new FileOutputStream("DebugOutput.log",
							true),
				   true);
	    mTest
		= new PrintStream(new FileOutputStream("TestOutput.log", true),
				  true);
	    mCalendar = Calendar.getInstance();
	} catch (FileNotFoundException filenotfoundexception) {
	    throw new RuntimeException("Failed to start TestTools.");
	}
    }
    
    public void finalize() {
	mLog.close();
	mTest.close();
    }
    
    public static synchronized void assert2(boolean bool, String string) {
	if (!bool) {
	    System.out.println("*Assertion Failed* " + string);
	    logToFile("*Assertion Failed* " + string);
	    throw new RuntimeException("\n*Assertion Failed* " + string);
	}
    }
    
    public static synchronized void logToFile(String string) {
	if (mTestTools == null)
	    mTestTools = new TestTools();
	mTestTools.mLog.print("\n*" + mTestTools.mCalendar.getTime() + "*\n"
			      + string + "\n");
    }
    
    public static synchronized void logToTest(String string) {
	if (mTestTools == null)
	    mTestTools = new TestTools();
	mTestTools.mTest.println(string);
    }
}
